package com.practice.mapper.admin;

import com.practice.pojo.admin.entity.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AdminIndexMapper {

    @Select("select attr_value from sys_config where tab_value = 'system' ")
    List<String> config();

    //获取全部用户菜单权限
//    @Select("select * from sys_menu where type = 1")
//    List<MenuList> selectMenu();

    //获取接口类型
    @Select("select value,label from sys_dict where type = #{interfaceType}")
    List<Dict> getByinterface(String interfaceType);

    //获取交易类型
    @Select("select value,label from sys_dict where type = #{orderType}")
    List<Dict> getByOrder(String orderType);

    //获取报告类型
    @Select("select value,label from sys_dict where type = #{reportType}")
    List<Dict> getByReport(String reportType);

    //获取表类型
    @Select("select value,label from sys_dict where type = #{tableType}")
    List<Dict> getByTable(String tableType);

    //获取主题类型
    @Select("select value,label from sys_dict where type = #{theme}")
    List<Dict> getByTheme(String theme);

    //根据用户id查询rold_id
    @Select("select role_id from sys_user where id= #{currentId}")
    String getByRole(Long currentId);

    //根据rold_id查询rolename
    @Select("select name from sys_role where id = #{role_id}")
    String getByRoleName(String role_id);


    @Select("select * from sys_user where id = #{userId}")
    User selectUser(Long userId);


    //所有分类数据
    @Select("select * from ydd_cate")
    List<AdminCate> getByCate();

    @Select("SELECT * FROM ydd_user ORDER BY id DESC LIMIT 6")
    List<AdminYddUser> getByYddUser();

    @Select("select * from ydd_article")
    List<AdminHotArticle> getByHotArticle();


    /**
     * 查询总用户数量
     * @return
     */
    @Select("select count(*) from ydd_user")
    Integer getByTotal();

    @Select("select count(sex) from ydd_user where sex = #{man}")
    Integer getByMan(String man);

    @Select("select count(sex) from ydd_user where sex = #{woman}")
    Integer getByWomen(String woman);

    //广告位总数
    @Select("select count(*) from ydd_advimg")
    Integer getByAdvposNum();

    //标签总数
    @Select("select count(*) from ydd_tag")
    Integer getByTag();

    //管理员总数
    @Select("select count(*) from sys_role")
    Integer getByAdminNum();

    //文章总数
    @Select("select count(*) from ydd_article")
    Integer getByArticleNum();

    //分类总数
    @Select("select count(*) from ydd_cate")
    Integer getByCateNum();

    //广告图总数
    @Select("select count(*) from ydd_advimg")
    Integer getByAdvimgNum();


//    @Select("select sys_menu.* from sys_role_menu " +
//            "inner join sys_menu on sys_menu.id = sys_role_menu.menu_id where sys_role_menu.role_id = #{roleId} and type = 1")
    @Select("SELECT * FROM  sys_menu WHERE TYPE = 1")
    List<MenuList> selectMenu(String roleId);

}
